import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Button } from 'antd';

const classNames = require('classnames');

class Office extends Component {
  state = {
    count: 0,
    visible: false,
  }
  handleClick =() => {
    this.setState({ count: this.state.count + 1 });
  }
  componentWillReceiveProps (nextProps) {
    this.setState({
      visible: nextProps.visible,
    });
  }
  render () {
    const className = classNames('office-view', { hide: !this.state.visible });
    return (
      <div className={className}>
        <h3>{this.state.count}</h3>
        <Button onClick={this.handleClick}>Click</Button>
      </div>
    );
  }
}

Office.propTypes = {
  visible: PropTypes.bool.isRequired,
};

export default Office;
